import React, { Component } from 'react'

import store from './store'

export default class App extends Component {
  increment = () => {
    store.dispatch({type: 'increment'})
  }

  decrement = () => {
    store.dispatch({type: 'decrement'})
  }
  // * 组件没有渲染 subscribe 没有订阅，状态发生变化需要重新渲染组件
  render() {
    return (
      <div>
        <button onClick={this.decrement}> - </button>
        <span>{store.getState().count}</span>
        <button onClick={this.increment}> + </button>
      </div>
    )
  }

}
